class PrivaciesController < ApplicationController
  def edit
    @entity = User.find(session[:user_id])
    @privacy = @entity.privacy_level    
  end

  def update
     @entity = User.find(session[:user_id])
     @privacy = @entity.privacy_level
     
     respond_to do |format|
      if(@privacy.update_attributes(:search => params[:setting_search].to_i,
                                    :requests => params[:setting_requests].to_i,
                                    :stream_view => params[:setting_show_stream].to_i,
                                    :private_messaging => params[:setting_private_messages].to_i))                                
        format.html { redirect_to(entity_path(@entity), :notice => 'Privacy settings were successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @privacy.errors, :status => :unprocessable_entity }
      end
    end
  end
end
